package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.service.FootprintService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("wx/footprint")
public class footprintWxController {

    @Autowired
    FootprintService footprintService;
    @RequestMapping("list")
    public BaseRespVo list(Integer page,Integer size){
        Subject subject = SecurityUtils.getSubject();
        Integer userId = (Integer) subject.getPrincipal();
        //todo 补userId
//        Integer userId = 1;
        Map footprintList = footprintService.selectList(page,size,userId);
        return BaseRespVo.ok(footprintList);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody Map map){
        Integer id = (Integer) map.get("id");
        footprintService.deleteFootprint(id);
        return BaseRespVo.ok();
    }
}
